<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<meta name="format-detection" content="telephone=no" />
<title></title>

<link rel="stylesheet" type="text/css" href="{cms>:RES}/QA/css/qa.css" />
<script src="{cms>:RES}/QA/js/zepto.min.js" type="text/javascript"></script>
<script src="{cms>:RES}/QA/js/funtest.js?v=2" type="text/javascript"></script>

</head>
<body>

	<div class="container">

		<h1 class="test_title">
			测测你该如何预防小三(<span class="curr_index">1</span>/14)
		</h1>

		<div class="question_c">
			<div class="question_box">
				<h3 class="question_title">1.如果在街上遇到不道德的事情，你会站出来指出吗？</h3>
				<ul class="items_c">
					<li class="no_selectable question_item "
						onclick="save_value('A', this)">A. 是</li>
					<li class="no_selectable question_item "
						onclick="save_value('B', this)">B.不是</li>
				</ul>
			</div>
		</div>

		<div class="qustion_nav">

			<span class="go_previous hide">
			<a href="javascript:go_previous()" class="prev_link">上 一 题</a>
			</span>
			<span class="go_done hide">
			<a href="javascript:go_done()" class="prev_link done">完 成</a></span>

		</div>

	</div>
	
	<script type="text/javascript">
  $(function(){
    try{
      Funtest.setHideItem(false).setTestid(1).setTemplate('normal_item');
    } catch(e) {
      console.log(e);
    }
    $.get("/fun_tests/test.json?testid=27&userid=&_"+(new Date()).getTime(), function(data){
      Funtest.setData(data);
      $.get("/fun_tests/answer.json?testid=27&userid=&_"+(new Date()).getTime(), function(data){
        // console.log(data);
        Funtest.setAnswer(data).renderFirstItem();
      });
    });
  })

  function save_value(val, obj) {
    mark(obj);
    setTimeout(function(){
      Funtest.saveValue(val);
    }, 200);
  }

  function go_previous() {
    Funtest.renderPreviousItem();
  }

  function go_done() {
    if($(".selected_item").length < 1) {
      return;
    }
    self.location = "/fun_tests/calc_result?testid=27&userid=";
  }

  function show_previous() {
    $("span.go_previous").show();
  }

  function hide_previous() {
    $("span.go_previous").hide();
  }

  function show_done() {
    $("span.go_done").show();
  }

  function hide_done() {
    $("span.go_done").hide();
  }

  function mark(obj) {
    //clear first
    $(".selected_item").removeClass("selected_item");

    // add seleted class
    $(obj).addClass("selected_item");
    $(obj).find(".question_item_text").addClass("selected_item");
  }

  function send_result(testid, qid, val) {
    $.post("/fun_tests/save_answer", {
      testid: this.testid,
      qid: this.qid,
      userid: '',
      value: val
    });
  }

  function update_index(index) {
    $('.curr_index').text(index);
  }

  Funtest.setControllFunctions(
    show_previous,
    hide_previous,
    show_done,
    hide_done,
    update_index,
    send_result,
    go_done
  );

</script>

</body>
</html>